// DOM树构建完成后
$(document).ready(function () {
	if ($.fn.cssOriginal!=undefined)   // CHECK IF fn.css already extended  
  	$.fn.css = $.fn.cssOriginal;  
    $('.fullwidthbanner').revolution(  
       {      
			dottedOverlay:"ershiwublack",
			delay:5000,
			startwidth:1200,
			navigationType:"bullet",
			onHoverStop:"on" 
                          
       });  

   	$(".right_server li:odd").css("margin-right","0px");
   	$(".way").mouseenter(function(event) {
		$(this).children('.open_box').show();
	}).mouseleave(function(event) {
		$(this).children('.open_box').hide();
	});

	var wh = $(window).height();
	var sh = $('.service').height()
	var top = (wh-sh)/2;   
    $(".service").css({"top":top});

    $(".top").click(function () {
        var speed=800;//滑动的速度
        $('body,html').animate({ scrollTop: 0 }, speed);
        return false;
 	});
	new AdvImg($('.chart'));
});
/**
 * 优势图效果
 *
 * @class
 */
function AdvImg(obj) {
	this.obj = obj;
	this.bgWidth = 1080;
	this.objHeight = 268;
	this.duration = 1000;
	this.bgImg = this.obj.find('.bg_data');
	this.isBgShow = false;

	this.init();
}
AdvImg.prototype = {
	constructor: AdvImg,
	// 初始化
	init: function () {
		$(window).on('scroll', $.proxy(this.scrollShow, this));
	},

	// 获取元素据顶部的高度
	getTop: function (obj) {
		var topValue = 0;
		var topObj = obj.get(0);
		while(topObj) {
			topValue +=topObj.offsetTop;
			topObj = topObj.offsetParent;
		}
		return topValue;
	},

	// 统计图出现时
	scrollShow: function () {
		var objTop = this.getTop(this.obj)
		var wHeight = document.documentElement.clientHeight;
		var scrollTop = $('body').scrollTop() || $('html').scrollTop();
		
		if (scrollTop > objTop -(wHeight - this.objHeight) 
			&& scrollTop < objTop + this.objHeight) {
			if (!this.isBgShow) {
				this.bgIn();
				this.isBgShow = true;
			}
		}
		else {
			if (this.isBgShow) {
				this.bgHide();
				this.isBgShow = false;
			};
		}
	},

	// 淡出背景
	bgIn: function () {
		this.bgImg.animate({'width': this.bgWidth + 'px'}, this.duration);
	},

	// 隐藏背景
	bgHide: function () {
		this.bgImg.css('width',0);
	}
}
